package com.info.zhiduoduo.repository.mapper.company;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.info.zhiduoduo.repository.entity.company.CompanyApply;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author tianyonghong
 * @create 2023/9/14
 */
public interface CompanyApplyMapper extends BaseMapper<CompanyApply> {

    @Select("select ca.*,c.compname,pay.pay_name as currCompPayName,ccp.company_name as currCompPartyName " +
            " from zdd_company_apply ca" +
            " left join zdd_company c on ca.compid = c.compid" +
            " left join zdd_payment pay on pay.id = ca.curr_comp_pay_id " +
            " left join zdd_crowdsource_company_party ccp on ccp.id = ca.curr_comp_party_id " +
            " where 1=1 " +
            " and if(#{compid} = 0, 1=1, ca.compid = #{compid})" +
            " and IF(ISNULL(#{compname}) or #{compname} = '', 1 = 1, c.compname like '%${compname}%')" +
            " and if(#{type} = 0, 1=1, ca.type = #{type})" +
            " and if(#{state} = 0, 1=1, ca.state = #{state})" +
            " and IF(ISNULL(#{content}) or #{content} = '', 1 = 1, ca.content like '%${content}%')" +
            " order by ca.id desc ")
    List<CompanyApply> queryList(int compid,String compname,int type,int state,String content);

    //查询待审核数量
    @Select("SELECT count(1) FROM zdd_company_apply WHERE state = 1")
    Integer queryPendingNum();
}
